package tp.pr4.items;

import tp.pr4.Door;
import tp.pr4.Player;
import tp.pr4.Room;

public class Key extends PersistentItem
{

	private Door door;

	public Key(String id,String description, Door door)
	{
		super(id, description);
		this.door = door;

	}


	public boolean use(Player who, Room where)//Funciona seguro?si NO es "bidi"?
	{
		if (!(where != null && this.door != null && this.door.isInRoom(where))) {
			System.out.println("I did not go to TP classes last week, I do not know how to use it...");

			return false;
		}
		
		
		if (this.door.isOpen())
		{
			this.door.close();
			System.out.println("Something changes ...");

			return true;
		}

		this.door.open();
		System.out.println("Something changes ...");
		return true;
		
	}
}
